package com.starview.star.compiler.util;

import java.util.Iterator;

public class StringIterator implements Iterator<Integer>
{
  private final String content;
  private int cx = 0;
  private final int length;

  public StringIterator(String content)
  {
    this.content = content;
    this.length = content.length();
  }

  @Override
  public boolean hasNext()
  {
    return cx < length;
  }

  @Override
  public Integer next()
  {
    int next = content.codePointAt(cx);
    cx = content.offsetByCodePoints(cx, 1);
    return next;
  }

  @Override
  public void remove()
  {
    throw new UnsupportedOperationException("not permitted");
  }
}
